<?php
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );
RClassesImporter::cls("dbo.dtos.ImageDTO" );

class ImageModel {

	function delete($arrId) {
		$result = false;
		if (is_array($arrId)) {
			$arrId = implode(',', $arrId);
		}
		$sQuery		=	"DELETE FROM image WHERE image_id IN ({$arrId}) ";
		return SysDatabase::execute( $sQuery );
	}
	
	function getImageDetails($id) {
		$my_Obj = new ImageDTO();
		$my_Obj->setKeyValue($id);
		SysDatabase::fillData($my_Obj);
		return $my_Obj;
	}
	
	function getAlbumImageMapping($arrayOrObjectValues) {
		RClassesImporter::cls('dbo.mapping.AlbumImageMapping');
		$mapping = new AlbumImageMapping();
		$mapping->bind($arrayOrObjectValues);
		return $mapping;
	}
	
	function saveImageDTO($dto){
		return SysDatabase::saveDTO($dto);
	}

	function getTranscationLog($id) {
		$finder = new TranscationFinder();
		$finder->member_id = $id;
		return SysDatabase::getSelectResult($finder->getSelectSQL());
	}
	
	/**
	 * 
	 * Get albums with paging
	 * 
	 * @param $page
	 * @param $limit
	 * @return SelectResult
	 */
	function getAlbumsPaging($page, $limit = 3) {
		$sql = "SELECT * FROM album WHERE enabled = '1' ORDER BY album_id DESC";
		return SysDatabase::getSelectResult($sql, $limit, $page);
	}
	
	/**
	 * 
	 * Get video with paging
	 * @param $page
	 * @param $limit
	 * @return SelectResult
	 */
	function getVideoPaging($page, $limit = 3) {
		$sql = "SELECT * FROM video WHERE enabled = '1' ORDER BY video_id DESC";
		return SysDatabase::getSelectResult($sql, $limit, $page);
	}
}
?>